package cn.school.classManage.service.impl;

import cn.school.classManage.entity.ClassCurriculumUser;
import cn.school.common.utils.SysUserUtils;
import cn.school.sys.entity.SysUser;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.school.classManage.entity.ClassCurriculumMiaosu;
import cn.school.classManage.service.ClassCurriculumMiaosuService;
import cn.school.classManage.dao.ClassCurriculumMiaosuMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 */
@Service
public class ClassCurriculumMiaosuServiceImpl extends ServiceImpl<ClassCurriculumMiaosuMapper, ClassCurriculumMiaosu>
    implements ClassCurriculumMiaosuService{
    @Resource
    ClassCurriculumMiaosuMapper classCurriculumMiaosuMapper;


    @Override
    public ClassCurriculumMiaosu selectMonday(ClassCurriculumMiaosu miaosu) {
        ClassCurriculumMiaosu curriculumMiaosu = classCurriculumMiaosuMapper.selectMonday(miaosu.getSessionsId(), miaosu.getClassId(), miaosu.getModeTime());
        return curriculumMiaosu;
    }

    @Override
    public List<ClassCurriculumMiaosu> selectAll() {
        return classCurriculumMiaosuMapper.selectAll();
    }

    @Override
    public Integer addMiaoShu(ClassCurriculumMiaosu miaosu) {
        int num=0;
        ClassCurriculumMiaosu curriculumMiaosu = selectMonday(miaosu);
        if(curriculumMiaosu==null){
            Long id = SysUserUtils.getSysUser().getId();
            miaosu.setCreateBy(String.valueOf(id));
            miaosu.setAddTime(new Date());
            num = classCurriculumMiaosuMapper.insert(miaosu);
        }else{
            miaosu.setId(curriculumMiaosu.getId());
            num = classCurriculumMiaosuMapper.updateById(miaosu);
        }
        return num;
    }

}




